package com.qf.shopitem.config;

import com.qf.common.constant.RabbitMqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitMqConfig {
    //这个是goods的交换机，不会重复生成
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange(RabbitMqConstants.GOODS_EXCHANGE, true, false);
    }

    @Bean
    public Queue ItemQueue() {
        return new Queue(RabbitMqConstants.GOODS_QUEUE_ITEM, true, false, false);
    }

    @Bean
    public Binding ItemBinding() {
        return BindingBuilder.bind(ItemQueue()).to(fanoutExchange());
    }

}
